* @defgroup Language Language
*/
-if ( !defined( 'MEDIAWIKI' ) ) {
- echo "This file is part of MediaWiki, it is not a valid entry point.\n";
- exit( 1 );
-}
-
-mb_internal_encoding( 'UTF-8' );
-
use CLDRPluralRuleParser\Evaluator;
/**
* xin n (month number) in Iranian calendar
* xiy y (two digit year) in Iranian calendar
* xiY Y (full year) in Iranian calendar
+ * xit t (days in month) in Iranian calendar
+ * xiz z (day of the year) in Iranian calendar
*
* xjj j (day number) in Hebrew calendar
* xjF F (month name) in Hebrew calendar
* @throws MWException
* @return string
*/
- public function sprintfDate( $format, $ts, DateTimeZone $zone = null, &$ttl = null ) {
+ public function sprintfDate( $format, $ts, DateTimeZone $zone = null, &$ttl = 'unused' ) {
$s = '';
$raw = false;
$roman = false;
}
$num = substr( $iranian[0], -2 );
break;
+ case 'xit':
+ $usedIranianYear = true;
+ if ( !$iranian ) {
+ $iranian = self::tsToIranian( $ts );
+ }
+ $num = self::$IRANIAN_DAYS[$iranian[1] - 1];
+ break;
+ case 'xiz':
+ $usedIranianYear = true;
+ if ( !$iranian ) {
+ $iranian = self::tsToIranian( $ts );
+ }
+ $num = $iranian[3];
+ break;
case 'a':
$usedAMPM = true;
$s .= intval( substr( $ts, 8, 2 ) ) < 12 ? 'am' : 'pm';
}
}
- if ( $usedSecond ) {
+ if ( $ttl === 'unused' ) {
+ // No need to calculate the TTL, the caller wont use it anyway.
+ } elseif ( $usedSecond ) {
$ttl = 1;
} elseif ( $usedMinute ) {
$ttl = 60 - substr( $ts, 12, 2 );
$jDayNo = floor( ( $jDayNo - 1 ) % 365 );
}
+ $jz = $jDayNo;
+
for ( $i = 0; $i < 11 && $jDayNo >= self::$IRANIAN_DAYS[$i]; $i++ ) {
$jDayNo -= self::$IRANIAN_DAYS[$i];
}
$jm = $i + 1;
$jd = $jDayNo + 1;
- return [ $jy, $jm, $jd ];
+ return [ $jy, $jm, $jd, $jz ];
}
/**
* @return string
*/
public function iconv( $in, $out, $string ) {
- # This is a wrapper for iconv in all languages except esperanto,
- # which does some nasty x-conversions beforehand
-
# Even with //IGNORE iconv can whine about illegal characters in
# *input* string. We just ignore those too.
# REF: http://bugs.php.net/bug.php?id=37166
}
}
+ /**
+ * @deprecated No-op since 1.28
+ */
function initEncoding() {
- # Some languages may have an alternate char encoding option
- # (Esperanto X-coding, Japanese furigana conversion, etc)
- # If this language is used as the primary content language,
- # an override to the defaults can be set here on startup.
+ // No-op.
}
/**
* @param string $s
* @return string
+ * @deprecated No-op since 1.28
*/
function recodeForEdit( $s ) {
- # For some languages we'll want to explicitly specify
- # which characters make it into the edit box raw
- # or are converted in some way or another.
- global $wgEditEncoding;
- if ( $wgEditEncoding == '' || $wgEditEncoding == 'UTF-8' ) {
- return $s;
- } else {
- return $this->iconv( 'UTF-8', $wgEditEncoding, $s );
- }
+ return $s;
}
/**
* @param string $s
* @return string
+ * @deprecated No-op since 1.28
*/
function recodeInput( $s ) {
- # Take the previous into account.
- global $wgEditEncoding;
- if ( $wgEditEncoding != '' ) {
- $enc = $wgEditEncoding;
- } else {
- $enc = 'UTF-8';
- }
- if ( $enc == 'UTF-8' ) {
- return $s;
- } else {
- return $this->iconv( $enc, 'UTF-8', $s );
- }
+ return $s;
}
/**
return $lang;
}
+ /**
+ * Compare with an other language object
+ *
+ * @since 1.28
+ * @param Language $lang
+ * @return boolean
+ */
+ public function equals( Language $lang ) {
+ return $lang->getCode() === $this->mCode;
+ }
+
/**
* Get the internal language code for this language object
*